﻿Imports Ocean.OceanFramework.WPF.Utility.Helpers
Partial Public Class ApplicationMainWindow
    Inherits Window

    'The ApplicationMainWindowViewModel RequestClose event is wired here in Application.xaml.vb
    Public Sub RequestClose(ByVal sender As Object, ByVal e As EventArgs)
        Me.Close()
    End Sub

    Private Sub ApplicationMainWindow_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles Me.Closing

        If Me.DataContext IsNot Nothing Then
            'this ensures that if the user clicked the Close Form "X" or typed ALT-F4
            'that a TextBox with an entry that has not completed will cause Data Bindings to update.
            UpdateFocusedField()
            '
            e.Cancel = Not CType(Me.DataContext, ApplicationMainWindowViewModel).CanApplicationClose
        End If

    End Sub

End Class
